#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<assert.h>

#define MAX_SIZE 100

void Build_next(const char *t, int *next){
    assert(t);
    // 遍历 模版串t
    int i = 0;
    // 遍历 前缀
    int j = -1;
    int sz = strlen(t);
    next[0] = -1;
    while(i < sz && j < sz){
	if(j < 0 || t[i] == t[j]){
	    next[++i] = ++j;
	}
	else{
	    j = next[j];
	}
    }
}


int KMP_match(const char *s, const char *t, int pos){
    int i = pos; int j = 0;
    int sz_s = (int)strlen(s);
    int sz_t = (int)strlen(t);
    
    int *next = (int*)malloc((sizeof(int)+5)*sz_t); 
    Build_next(t, next);
    while(i < sz_s && j < sz_t){
	if(j < 0 || s[i] == t[j]){++i,j++;}
	else{
	    j = next[j];
	}
    }
}


int main(){
    char* s = (char*)malloc(MAX_SIZE);
    char* t = (char*)malloc(MAX_SIZE);
    scanf("%s",s);
    scanf("%s",t);
    int pos = KMP_match(s,t,0);
    printf("pos:%d remain:%s\n",pos,s + pos);

    return 0;
}
